package com.login.springboot.service.impl;

import com.login.springboot.dao.UserDao;
import com.login.springboot.entity.User;
import com.login.springboot.service.UserService;
import com.login.springboot.util.MyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public MyResult login(User condition){
       User user=userDao.login(condition);
        MyResult result = new MyResult ();
        List<User> list=new ArrayList<>();
        list.add(user);
        if(list.size()!=0){
            result.setCode(0);
            result.setMsg("登录成功!");
            result.setList(list);
            result.setObj(list.get(0));
        }else{
            result.setCode(1);
            result.setMsg("登录失败");
        }
       return result;

    }
}
